<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/shop/product/">商品列表</a></li>
		<c:if test="${fns:getUser().roleIdList.contains('1')}">
		<shiro:hasPermission name="shop:product:edit"><li><a href="${ctx}/shop/product/form">商品添加</a></li></shiro:hasPermission>
		</c:if>
	</ul>
	<form:form id="searchForm" modelAttribute="product" action="${ctx}/shop/product/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<%--<li><label>序号：</label>
				<form:input path="id" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>--%>
			<li><label>商品名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>商品价格：</label>
				<form:input path="price" htmlEscape="false" class="input-medium"/>
			</li>
			<li><label>商品品牌：</label>
				<form:input path="brand" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>店铺名称：</label>
				<form:input path="sellshop" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<%--<li><label>商品图片：</label>
				<form:input path="img" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>--%>
			<li><label>关键字：</label>
				<form:input path="keyword" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<li><label>库存：</label>
				<form:input path="stock" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			<%--<li><label>详情介绍：</label>
				<form:input path="detalls" htmlEscape="false" class="input-medium"/>
			</li>--%>
			<li><label>类别类型：</label>
				<%--<form:input path="type" htmlEscape="false" maxlength="255" class="input-medium"/>--%>
				<form:select path="category.id" class="input-xlarge">
					<form:option value="" label="请选择"/>
					<form:options items="${categorylist}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>商品名称</th>
				<th>商品价格</th>
				<th>商品品牌</th>
				<th>商品所属店铺名称</th>
				<th>商品图片</th>
				<%--<th>关键字查询</th>--%>
				<th>库存数量</th>
				<%--<th>详情介绍</th>--%>
				<th>商品所属类别类型</th>
				<th>更新时间</th>
				<th>备注</th>
				<shiro:hasPermission name="shop:product:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="product">
			<tr>
				<td title="${product.name}"><a href="${ctx}/shop/product/form?id=${product.id}">
					${fns:abbr(product.name,10)}
				</a></td>
				<td>
					${product.price}
				</td>
				<td>
					${product.brand}
				</td>
				<td>
					${product.sellshop}
				</td>
				<td>
					<c:forEach items="${product.imgList}" var="i">
					<img src="${i}" style="width: 100px;height: 50px">
					</c:forEach>
				</td>
				<%--<td>
					${product.keyword}
				</td>--%>
				<td>
					${product.stock}
				</td>
			<%--	<td title="${product.detalls}">
					${fns:abbr(product.detalls,30)}
				</td>--%>
				<td>
					${product.category.name}
				</td>
				<td>
					<fmt:formatDate value="${product.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${product.remarks}
				</td>
				<c:if test="${fns:getUser().roleIdList.contains('1')}">
				<shiro:hasPermission name="shop:product:edit"><td>
    				<a href="${ctx}/shop/product/form?id=${product.id}">修改</a>
					<a href="${ctx}/shop/product/delete?id=${product.id}" onclick="return confirmx('确认要删除该商品吗？', this.href)">删除</a>
					</td>
				</shiro:hasPermission>
				</c:if>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>